<template>
	<view class="flex-col page bg_color">
		<view class="flex-col list">
			<view @click="toDetail(item)" class="list-item flex-col" :key="i" v-for="(item, i) in list">
				<image class="image_5" :src="item.image" />
				<text class="text_3">{{item.name}}</text>
				<text class="text_5">{{item.describe}}</text>
			</view>
		</view>
		<u-loadmore v-if="list != ''" icon-color="#D19A60" color="#D19A60" @loadmore="loadmore" margin-bottom="20"
			:load-text="loadText" :status="status" />

		<u-tabbar :list="tabbar" :mid-button="false"></u-tabbar>
	</view>
</template>

<script>
	var that;
	var vk;
	export default {
		data() {
			return {
				tabbar: [],
				list: [],
				status: 'loadmore',
				pageIndex: 1,
				pageSize: 10,
				loadText: {
					loadmore: '点击或上拉加载更多',
					loading: '正在加载，请稍后...',
					nomore: '到底了'
				}
			}
		},
		onReachBottom() {
			if (this.status == 'nomore') return
			this.status = 'loading';
			this.pageIndex = ++this.pageIndex;
			this.loadmore();
		},
		onLoad() {
			that = this;
			vk = that.vk;
			let base_info = uni.getStorageSync('base_info')
			that.tabbar = base_info.tabbar
			this.loadmore()
		},
		methods: {
			toDetail(item) {
				vk.navigateTo('/pages/case-detail/case-detail?_id=' + item._id)
			},
			loadmore() {
				that.$api.dcase({
					pageIndex: that.pageIndex,
					pageSize: that.pageSize
				}).then((data) => {
					if (data.code == 0) {
						if (!data.hasMore) {
							that.status = 'nomore'
						}
						that.list = that.list.concat(data.rows)
					} else {
						vk.toast('网络开小差了~')
					}
				}).catch((err) => {

				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		width: 100%;
		height: 100%;
		overflow-y: auto;

		.list {
			padding: 31rpx 30rpx 126rpx;
			flex: 1 1 auto;
			overflow-y: auto;

			.list-item {
				&:not(:first-of-type) {
					margin-top: 36rpx;
				}

				.image_5 {
					border-radius: 6rpx;
					filter: drop-shadow(0px 10rpx 10rpx #0000000d);
					width: 92vw;
					height: 58.5vw;
				}

				.text_3 {
					margin-top: 20rpx;
					color: rgb(34, 34, 34);
					font-size: 28rpx;
					font-weight: 500;
					line-height: 40rpx;
					white-space: nowrap;
				}

				.text_5 {
					margin-right: 10rpx;
					margin-top: 10rpx;
					color: rgb(153, 153, 153);
					font-size: 20rpx;
					line-height: 34rpx;
					text-align: left;
					text-transform: uppercase;
				}
			}
		}
	}
</style>
